Repository navigation
fix(mermaid): emit mermaid diagrams in a raw html block - #14767
Merged
Merged
Conversation
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
A bare `---` line in a mermaid diagram, such as the closing delimiter of
mermaid's own front matter, was read as a YAML front matter delimiter when
quarto split the document into cells. It hid the rest of the document, so
`ojs` cells placed after a mermaid diagram never reached the ojs compiler
and rendered as plain code.
Wrapping the `<pre>` element in a `{=html}` raw block keeps the cell
splitter out of the diagram source. Pandoc's markdown reader already
produced the same `RawBlock (Format "html")` for the bare html block, so
the rendered output does not change.
Also removes the commented-out mermaid tooltip code. Its note said
"removed until we use mermaid 10.0.0"; the bundled runtime is 11.12.0 and
mermaid now creates the `.mermaidTooltip` div itself.
mcanouil
force-pushed
the
fix/issue14765
branch
from
October 19, 2026 10:11
9c4cf28 to
47f9fdc
Compare
cderv
approved these changes
Oct 19, 2026
cderv
left a comment
Member
There was a problem hiding this comment.
Thanks for the fix. I checked that the smoke test fails when either the raw block or the fence sizing change is reverted, and the rendered HTML for other mermaid diagrams (blank lines, cross-ref with caption, revealjs) is unchanged apart from whitespace.
I'll push a small adjustment before merging: a unit test for the longest-run fence sizing in pandocBlock, covering the : div fences too as they go through the same code. No need to push anything meanwhile.
pandocBlock is shared by code fences and div fences, but the smoke test only reaches the backtick path through a mermaid cell. These unit tests pin both delimiters directly: content with a short run first and a longer run later must get a fence longer than the longest run. Both cases fail with the previous first-run sizing.
2 of 5 tasks
cderv
added a commit
that referenced
this pull request
Oct 19, 2026
Categories containing a backtick run longer than the first one, or any backslash, rendered broken in the page title block. A Windows path failed the whole render with "couldn't read native", and a backslash sequence such as \n was silently changed. pandocNativeStr now sizes the inline-code delimiter from the longest backtick run and escapes backslashes before quotes, so the text reaches pandoc as written. - Size the inline-code delimiter from the longest backtick run - Escape backslashes in the pandoc-native string literal - Add unit tests for backtick and backslash input See #14767
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A
mermaiddiagram with its own---configuration block hid the rest of the document, andojscells after it never ran.The diagram source went into the intermediate markdown as a bare
<pre>, so its closing---was read as the start of YAML front matter.The
<pre>now goes inside a{=html}raw block, which the markdown splitter does not look into.The HTML output is the same, because Pandoc already read the bare
<pre>as an HTML raw block.pandocBlocknow sizes that fence from the longest backtick run in the content, not the first one.Before, a diagram with a single backtick in one label and a line starting with three backticks later on closed the raw block early.
The commented-out tooltip code is gone, since Mermaid 11.12 creates
.mermaidTooltipitself.The smoke-all test covers both cases, and the backtick case fails when the fence change is reverted.
A Playwright test checks that the SVG keeps
aria-roledescription,<title>fromaccTitleand<desc>fromaccDescrin Chromium, Firefox and WebKit.It guards Mermaid's own accessibility output, which the raw block must keep.
Closes #14765
Checklist
I have (if applicable):
AI-assisted PR
Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.